package highlighter.parser;
import java_cup.runtime.*;
%%

%public
%class HighlighterLexer

%line
%column
%cup

%{   
    /* To create a new java_cup.runtime.Symbol with information about
       the current token, the token will have no value in this
       case. */
    private Symbol symbol(int type) {
        return new Symbol(type, yyline, yycolumn);
    }
    
    /* Also creates a new java_cup.runtime.Symbol with information
       about the current token, but this object has a value. */
    private Symbol symbol(int type, Object value) {
        return new Symbol(type, yyline, yycolumn, value);
    }
%}

%%

"using" 	{ return symbol(sym.K_USING); }
"namespace" { return symbol(sym.K_NAMESPACE); }
"class" 	{ return symbol(sym.K_CLASS); }
"interface" { return symbol(sym.K_INTERFACE); }
"public" 	{ return symbol(sym.K_PUBLIC); }
"private" 	{ return symbol(sym.K_PRIVATE); }
"protected" { return symbol(sym.K_PROTECTED); }
"static" 	{ return symbol(sym.K_STATIC); }
"return" 	{ return symbol(sym.K_RETURN); }
"get" 		{ return symbol(sym.K_GET); }
"set" 		{ return symbol(sym.K_SET); }
"if" 		{ return symbol(sym.K_IF); }
"else" 		{ return symbol(sym.K_ELSE); }
"while" 	{ return symbol(sym.K_WHILE); }
"for" 		{ return symbol(sym.K_FOR); }
"new" 		{ return symbol(sym.K_NEW); }
"null" 		{ return symbol(sym.K_NULL); }
"void" 		{ return symbol(sym.K_VOID); }
"int" 		{ return symbol(sym.K_INT); }
"float" 	{ return symbol(sym.K_FLOAT); }
"double" 	{ return symbol(sym.K_DOUBLE); }
"string" 	{ return symbol(sym.K_STRING); }
"bool" 		{ return symbol(sym.K_BOOL); }
"final"		{ return symbol(sym.K_FINAL); }

[a-z][a-zA-Z0-9_]*  { return symbol(sym.ID, yytext()); }
[0-9]+ 				{ return symbol(sym.NUMBER, new Integer(yytext())); }

"+"     { return symbol(sym.PLUS); }
"-"     { return symbol(sym.MINUS); }
"*"     { return symbol(sym.TIMES); }
"/"     { return symbol(sym.DIVIDE); }
"<"     { return symbol(sym.LT); }
">"     { return symbol(sym.GT); }
"("     { return symbol(sym.LP); }
")"     { return symbol(sym.RP); }
"{"     { return symbol(sym.LB); }
"}"     { return symbol(sym.RB); }
"="     { return symbol(sym.EQ); }
";"     { return symbol(sym.SEMI); }
","		{ return symbol(sym.COMMA); }
.|\n	{ }
